package de.slothsoft.commons.swing.validation;

import java.text.MessageFormat;

import javax.swing.JComboBox;

import de.slothsoft.commons.res.CommonMessages;

public class MandatoryComboBoxTester<S extends JComboBox<?>> implements
		ITester<S> {

	@Override
	public boolean acceptInput(S source) {
		Object selected = source.getSelectedItem();
		return selected != null;
	}

	@Override
	public String getErrorMessage(String sourceName) {
		return MessageFormat.format(
				CommonMessages.getString("Validator.mandatory"), sourceName);
	}

}
